<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.stat.EcStatPillar" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.JFreeChart" %>
<%@ page import="org.jfree.chart.axis.AxisLocation" %>
<%@ page import="org.jfree.chart.axis.CategoryAxis" %>
<%@ page import="org.jfree.chart.axis.ValueAxis" %>
<%@ page import="org.jfree.chart.labels.StandardCategoryItemLabelGenerator" %>
<%@ page import="org.jfree.chart.plot.CategoryPlot" %>
<%@ page import="org.jfree.chart.plot.PlotOrientation" %>
<%@ page import="org.jfree.chart.renderer.category.BarRenderer3D" %>
<%@ page import="org.jfree.data.category.CategoryDataset" %>
<%@ page import="org.jfree.data.category.DefaultCategoryDataset" %>
<%@ page import="java.awt.Color" %>
<%@ page import="java.awt.Font" %>
<%@ page import="java.io.IOException" %>
<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="org.jfree.chart.ChartFrame" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.servlet.ServletUtilities" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>统计查询</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is stat page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  
  <%

	  CategoryDataset dataset = EcStatPillar.getDataSet();

	  JFreeChart chart = ChartFactory.createBarChart3D("2010三大发电集团信息总览", // 图表标题
	    "收入与利润对照", // 目录轴的显示标签
	    "金额", // 数值轴的显示标签
	    dataset, // 数据集
	    PlotOrientation.VERTICAL, // 图表方向：水平、垂直
	    true, // 是否显示图例(对于简单的柱状图必须是false)
	    true, // 是否生成工具
	    true // 是否生成URL链接
	    );

	  // 设置Title和Legend的字体
	  chart.getTitle().setFont((new Font("宋体", Font.CENTER_BASELINE, 20)));
	  chart.getLegend().setItemFont(new Font("宋体", Font.CENTER_BASELINE, 15));

	  CategoryPlot plot = chart.getCategoryPlot();// 获得图表区域对象

	  // 设置纵横坐标的显示位置
	  plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);// 学校显示在下端(柱子竖直)或左侧(柱子水平)
	  plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // 人数显示在下端(柱子水平)或左侧(柱子竖直)

	  // 设置图表的横轴（X轴）
	  CategoryAxis domainAxis = plot.getDomainAxis();
	  EcStatPillar.setXDomainAxis(domainAxis);

	  // 设置图表的纵轴（Y轴）
	  ValueAxis valueAxis = plot.getRangeAxis();
	  EcStatPillar.setYDomainAxis(valueAxis);

	  // 设置图表的颜色
	  EcStatPillar.setRender(plot);

	  String filename = ServletUtilities.saveChartAsPNG(chart,900,500,session);
	  String graphURL = path + "/DisplayChart?filename=" + filename;
	  System.out.println("filename :" + graphURL);
	

	  // 将生成的报表放到预览窗口中
	  //ChartFrame preview = new ChartFrame("2010三大电力企业信息", chart);
	  //preview.pack();

	  // 显示报表预览窗口
	  //preview.setVisible(true); 

  
  %>
  <img src="<%=graphURL %>" />
  </body>
</html>
